package j39;

import cn.hutool.core.thread.ThreadUtil;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * @author chengshuai
 * @date 2021/4/15 12:14
 *
 * 测试解除阻塞
 */
public class BlockingQueueDemo4 {

    static BlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(3);
    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            try {
                ThreadUtil.sleep(1000);
                System.out.println("放入d");
                blockingQueue.put("d");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        f3();
    }
    public static void f3() throws InterruptedException {
        blockingQueue.put("a");
        blockingQueue.put("a");
        blockingQueue.put("a");
        System.out.println("=============");
        blockingQueue.take();
        blockingQueue.take();
        blockingQueue.take();
        blockingQueue.take();
    }
}
